package com.san.metadata.task;

import java.util.Date;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.san.common.utils.Constant;
import com.san.earlyWarning.domain.EarlyWarningDO;
import com.san.metadata.dao.OperationMetadataManager;

/**
 * 信用预警固话线程
 * @author hulp
 *
 */
public class EarlyWarningThread extends Thread {
	
	private static final Logger logger = LoggerFactory.getLogger(EarlyWarningThread.class);
	
	private OperationMetadataManager operationMetadataManager;
	
	private List<EarlyWarningDO> list;
	
	public EarlyWarningThread(OperationMetadataManager operationMetadataManager, List<EarlyWarningDO> list) {
		this.operationMetadataManager = operationMetadataManager;
		this.list = list;
	}
	
	@Override
	public void run() {
		Date date = new Date();
		Long batchNo = date.getTime();
		for (EarlyWarningDO earlyWarningDO : list) {
			if (earlyWarningDO.getDelFlag() == Constant.DEL_FLAG_NORMAL) {
					try {
						operationMetadataManager.fixingEarlyWarningMetadata(batchNo, earlyWarningDO);
					} catch (Exception e) {
						logger.error("固化信用预警失败",e);
					}
			}
			
		}
	}

}
